<template>
  <!-- 设计管理复盘报告 -->
  <base-breadcrumb class="flexMemberInfo-container">
    <!-- 搜索 -->
    <searchData
      :search-data="searchOption"
      @search="search"
    />

    <a-card>
      <!-- <title-name :title="'设计管理复盘报告列表'" /> -->

      <list-table
        ref="table"
        size="default"
        row-key="id"
        :columns="columns"
        :request="loadData"
        :alert="true"
        show-size-changer
        show-quick-jumper
      >
        <span
          slot="status"
          slot-scope="text, record"
        >
          <list-status
            :status="record.strStatusCode"
            :text="text"
          />
        </span>
        <span
          slot="operation"
          slot-scope="text,record"
        >
          <MoreButton>
          <template>
            <a @click="handleDetail('look', record.id)">查看</a>
          </template>
          <template v-if="(!record.strStatusCode || record.strStatusCode === 'DRAFT' || record.strStatusCode === 'REJECTED')&&hideBuquBtn()">
            <a @click="handleDetail('edit', record.id)">编辑</a>
          </template>
          <template v-if="record.strStatusCode && record.strStatusCode !== 'DRAFT'">
            <approval-button :id="record.id" text="审核信息" />
          </template>
            </MoreButton>
        </span>
      </list-table>
    </a-card>
  </base-breadcrumb>
  <!-- 设计管理复盘报告 -->
</template>
<script>
import SelectSubCompany from '@/components/Select/SelectSubCompany'
import SelectProject from '@/components/Select/SelectProject'
import { getReviewReportList } from '@/api/design/analyseReport'
import listStatus from '@/components/list_status2/list_status2.vue'
import OrgTreeSelect from '@/components/OrgTreeSelect'
// 搜搜列表
const searchOption = [
  {
    name: '所属单位',
    valueKey: 'searchQuery',
    type: OrgTreeSelect,
  },
  // {
  //   name: '所属分公司',
  //   valueKey: 'companyId',
  //   type: SelectSubCompany
  // },
  // {
  //   name: '所属项目',
  //   keyValue: 'companyId',
  //   valueKey: 'projectId',
  //   type: SelectProject
  // },
  {
    name: '会议名称',
    value: 'conferenceName',
    type: 'input'
  },
  {
    name: '召开时间',
    value: 'conferenceTime',
    type: 'dateRangeFormat',
  },
  {
    name: '状态',
    value: 'conferenceStatus',
    type: 'select',
    data: [
      { label: '待提交审核', value: 'DRAFT' },
      { label: '审核中', value: 'SUBMITTED' },
      { label: '审核通过', value: 'PAST' },
      { label: '审核不通过', value: 'REJECTED' }
    ]
  }
]
// 表头
const columns = [
  {
    title: '序号',
    width: '80px',
    align: 'center',
    customRender: (text, record, index) => {
      return index + 1
    }
  },
  {
    title: '会议名称',
    dataIndex: 'conferenceName'
  },
  {
    title: '所属分公司',
    dataIndex: 'companyName'
  },
  {
    title: '所属项目',
    dataIndex: 'projectName'
  },
  {
    title: '召开时间',
    dataIndex: 'conferenceBeginTime'
  },
  {
    title: '参会人数',
    dataIndex: 'conferenceNum'
  },
  {
    title: '状态',
    dataIndex: 'conferenceStatus',
    scopedSlots: { customRender: 'status' }
  },
  {
    title: '操作',
    dataIndex: 'operation',
    width: '180px',
    scopedSlots: { customRender: 'operation' }
  }
]
export default {
  name: 'Index',
  components: {
    // page
    listStatus
  },
  data() {
    return {
      // 搜搜列表
      searchOption,
      // 表头
      columns,
      // 查询参数
      queryParam: {},
      // 加载数据方法 必须为 Promise 对象
      loadData: async (parameter) => {
        const requestParameters = Object.assign({}, parameter, { param: this.queryParam })
        const datas = []
        requestParameters.pageNum = requestParameters.pageNo
        delete requestParameters.pageNo
        let res = await getReviewReportList(requestParameters)
        if (res.code == 0) {
          const datas = res.data.data.map((e) => {
            e.id = e.id.toString()
            return e
          })
          const obj = {
            code: 200,
            data: datas,
            currentPage: res.data.pageNumber,
            pageSize: res.data.pageSize,
            totalSize: res.data.totalElements
          }
          return obj
        }
        return { code: 200, data: [] }
      }
    }
  },
  mounted() {
  },
  methods: {
    search(value) {
      this.queryParam = value || {}
      // 'conferenceBeginTime',
      // 'conferenceEndTime'
      if (value.conferenceTime && value.conferenceTime.length > 0) {
        this.queryParam.conferenceBeginTime = this.queryParam.conferenceTimeStart
        this.queryParam.conferenceEndTime = this.queryParam.conferenceTimeEnd
        delete this.queryParam.conferenceTimeStart
        delete this.queryParam.conferenceTimeStartTime
        delete this.queryParam.conferenceTimeEnd
        delete this.queryParam.conferenceTimeEndTime
      }
      this.$refs.table.refresh()
    },
    handleDetail(type, id) {
      this.$router.push({
        path: '/project/design/analyse/analyseReport/edit',
        query: {
          type,
          id
        }
      })
    }
  }
}
</script>
<style lang="scss">
</style>
